package com.coffee.middleware.dict.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.coffee.core.ValidGroup;
import com.coffee.mybatis.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * @author songkui
 * @since 2024/5/9 14:54
 */
@Schema(description = "字典详情")
@Getter
@Setter
@EqualsAndHashCode(of ={"id"}, callSuper = false)
@Accessors(chain = true)
@NoArgsConstructor
@TableName("sys_dict_data")
public class DictDataEntity extends BaseEntity {

    @NotNull(groups = ValidGroup.Update.class, message = "ID不能为空")
    @Null(groups = ValidGroup.Create.class, message = "ID必须为空")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(description = "所属字典类型ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "字典类型ID必填")
    @TableField("type_id")
    private Integer typeId;

    @Schema(description = "字典编号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(groups = ValidGroup.Create.class, message = "字典编号码必填")
    @TableField("dict_code")
    private Integer dictCode;

    @Schema(description = "字典名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "字典名称必填")
    @TableField("dict_name")
    private String dictName;

    @Schema(description = "字典备注", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField("remark")
    private String remark;


    public DictDataDTO buildDTO(){
        DictDataDTO dto = new DictDataDTO();
//        dto.setTypeCode(typeCode);
        dto.setDictName(this.dictName);
        dto.setDictCode(this.dictCode);
        return dto;
    }


}
